<template>
	<div class="login">
		<!-- #ifdef MP-TOUTIAO -->
		<view class="weixin_auth_modal" >
			
			<view class='content'>
				<view>申请获取以下权限</view>
				<view>获得你的公开信息(昵称，头像、地区等)</view>
			</view>
			<p class="dyuserinfo" @click="getDYuserinfo">获取抖音授权</p>
			<!-- <button type="primary" open-type="getUserInfo" scope="userInfo" @getUserInfo="getDYuserinfo">
						登陆
					</button> -->
			<button class='bottom' style="margin-top: 0px; background-color: #e5e5e5;" type='primary' @click="back">
				暂不登陆
			</button>
		</view>
		<!-- #endif -->

	</div>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		
		methods: {
			//今日头条用户信息授权
			getDYuserinfo() {
				let that = this
				uni.login({
					provider: 'toutiao',
					success: function(loginRes) {
						console.log(loginRes);
		
						that.$u.api.login({
							appletId: that.vuex_appletId,
							code: loginRes.code
						}).then(res => {
							console.log(res,999999);
							
							uni.switchTab({
								url:"/pages/user/index"
							})
							that.$u.vuex('vuex_token', res.data.token);
						})
						
						
						
						// uni.getUserInfo({
						// 	success(res) {
						// 		console.log(res)
						// 		_this.needWxUserInfo = false;
						// 		_this.needWxMobile = true;
						// 		_this.authInfo = res.userInfo
						// 		uni.setStorageSync('authInfo', res.userInfo);
						// 		if (res) {
						// 			_this.$ajaxRequest({
						// 				url: 'ttauth',
						// 				options: {
						// 					method: 'post'
						// 				},
						// 				data: {
						// 					code: loginRes.code,
						// 					anonymous_code: loginRes.anonymousCode
						// 				},
						// 				success: (result) => {
						// 					_this.authInfo.openid = result.tt_data.openid
						// 					console.log(result)
						// 					console.log(_this.authInfo)
						// 					// _this.getPhoneNumber()
						// 				}
						// 			})
						// 		}
						// 	}
						// })
					}
				});
			}

		}
	}
</script>

<style scoped lang="scss">
	.weixin_auth_modal{
		color: #fff;
	}
</style>
